<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取引用所指向的对象</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodbref.create.html">MongoDBRef::create</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodbref.isref.html">MongoDBRef::isRef</a></div>
 <div class="up"><a href="class.mongodbref.html">MongoDBRef</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongodbref.get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDBRef::get</h1>
  <p class="verinfo">(PECL mongo &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">MongoDBRef::get</span> &mdash; <span class="dc-title">获取引用所指向的对象</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodbref.get-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">array</span> <span class="methodname"><strong>MongoDBRef::get</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.mongodb.html" class="type MongoDB">MongoDB</a></span> <code class="parameter">$db</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$ref</code></span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongodbref.get-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>

      <em><code class="parameter">db</code></em>
     </dt>

     <dd>

      <p class="para">
       使用的数据库。
      </p>
     </dd>

    
    
     <dt>

      <em><code class="parameter">ref</code></em>
     </dt>

     <dd>

      <p class="para">
       要获取的引用。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodbref.get-returnvalues">
  <h3 class="title">返回值</h3>  
  <p class="para">
   返回引用指向的文档，如果文档不存在则返回 <strong><code>NULL</code></strong>（该引用已损坏）。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongodbref.get-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1473">
   <p><strong>Example #1 <span class="function"><a href="mongocollection.createdbref.html" class="function">MongoCollection::createDBRef()</a></span> 例子</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;从&nbsp;db&nbsp;获取&nbsp;$person。<br /></span><span style="color: #0000BB">$person&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$people</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">findOne</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;解析引用的&nbsp;address<br /></span><span style="color: #0000BB">$address&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">MongoDBRef</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #0000BB">$people</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$person</span><span style="color: #007700">[</span><span style="color: #DD0000">'address'</span><span style="color: #007700">]);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodbref.get-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="mongodb.getdbref.html" class="methodname" rel="rdfs-seeAlso">MongoDB::getDBRef()</a> - Fetches the document pointed to by a database reference</span></li>
    <li class="member"><span class="methodname"><a href="mongocollection.getdbref.html" class="methodname" rel="rdfs-seeAlso">MongoCollection::getDBRef()</a> - Fetches the document pointed to by a database reference</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodbref.create.html">MongoDBRef::create</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodbref.isref.html">MongoDBRef::isRef</a></div>
 <div class="up"><a href="class.mongodbref.html">MongoDBRef</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
